package com.sairobo.admin.modules.wechat.servlet;


import com.sairobo.admin.modules.wechat.util.WechatUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;

/**
 *作废-仅供测试
 */
//@WebServlet("/WxAuth/wxLogin")
public class LoginServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String backUrl = "http://eureka-pc.sairobo.cn";
        String url = "https://open.weixin.qq.com/connect/oauth2/authorize?"
                + "appid=" + WechatUtil.APPID
                + "&redirect_uri=" + URLEncoder.encode(backUrl)
                + "&response_type=code"
                + "&scope=snsapi_login"
                + "&state=STATE"
                + "#wechat_redirect";
//        重定向用户请求到微信授权URL
        resp.sendRedirect(url);
    }
}
